<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>登录 | {$system_name}</title>
	<meta name="keywords" content="index">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="icon" type="image/png" href="{_ADMIN_STATIC_}/i/favicon.png">
	<link rel="apple-touch-icon-precomposed" href="{_ADMIN_STATIC_}/i/app-icon72x72@2x.png">
	<link rel="stylesheet" href="{_ADMIN_STATIC_}/css/amazeui.min.css" />
	<link rel="stylesheet" href="{_ADMIN_STATIC_}/css/admin.css">
	<link rel="stylesheet" href="{_ADMIN_STATIC_}/css/app.css">
</head>

<body data-type="login">

	<div class="am-g myapp-login">
		<div class="myapp-login-logo-block  tpl-login-max">
			<div class="myapp-login-logo-text">
				<div class="myapp-login-logo-text">
					成果<span> 管理系统</span> <i class="am-icon-skyatlas"></i>
				</div>
			</div>

			<div class="login-font">
				<i>成果 </i> 管理 <span> 系统</span>
			</div>
			<div class="am-u-sm-10 login-am-center">
				<div class="am-form">
					<fieldset>
						<div>
							<input type="text" id="account" placeholder="请输入账号">
						</div>
						<div style="margin-top: 5px;">
							<input type="password" id="password" placeholder="请输入密码">
						</div>
						<div style="margin-top: 5px;height: 100%;">
							<span style="height: 130%;">
								<input type="text" id="captcha" placeholder="请输入验证码"
									style="width: 70%;float: left;margin-right: 5%;">
							</span>
							<span>
								<img id="captcha_src" src="{:url('login/verify')}" style="height: 40px;width: 25%;">
							</span>
						</div>
						<p><button type="submit" class="am-btn am-btn-default" onclick="btn_login()">点击登录</button></p>

					</fieldset>
				</div>
			</div>
		</div>
	</div>

	<script src="{_ADMIN_STATIC_}/lib/jquery/jquery.js"></script>
	<script src="{_ADMIN_STATIC_}/js/amazeui.min.js"></script>
	<script src="{_ADMIN_STATIC_}/js/app.js"></script>

	<!-- 加载弹出层 -->
	<script src="{_ADMIN_STATIC_}/lib/layer/layer.js"></script>

	<script>

		// 验证码绑定事件
		// 用于刷新验证码
		$("#captcha_src").bind("click", function () {
			refresh_verification_code();
		});

		// 点击登录验证
		function btn_login() {
			$.ajax({
				url: "{:url('login/captcha_account')}",
				data: {
					'account': $('#account').val().trim(),
					'password': $('#password').val().trim(),
					'captcha': $('#captcha').val().trim()
				},
				type: "POST",
				dataType: "JSON",
				success: function (res) {
					// 返回结果处理
					if (res.code == 0) {
						layer.msg(res.msg, { icon: 1, time: 900 }, function () {
							window.location.href = "{:url('index/index')}";
						});
					} else {
						layer.msg(res.msg, { icon: 2, time: 900 });
						refresh_verification_code();
					}
				}
			});
		}

		// 刷新验证码
		function refresh_verification_code(){
			var timestamp = Date.parse(new Date());
			$("#captcha_src").attr("src", "{:url('login/verify')}?t=" + timestamp);
			$("#captcha").val('');			
		}


	</script>
</body>

</html>